--TEST--
resource MySQLndUhConnection::useResult(resource $connection)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
	require_once('config.inc');

	class proxy extends MySQLndUhConnection {
		public function useResult($res) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			var_dump($ret = parent::useResult($res));
			return $ret;
		}
	}

	class proxy2 extends MySQLndUhConnection {
		public function useResult($res) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			var_dump($ret = parent::useResult($res));
			return 12345;
		}
	}

	$conn = mysqlnd_uh_test\connect::mysqli();
	mysqlnd_uh_test\query_test::mysqli($conn);

	if (!$conn->real_query("SELECT 'without proxy' FROM DUAL"))
		printf("[001] [%d] '%s'\n", $conn->errno, $conn->error);

	if (!$res = $conn->use_result())
		printf("[002] [%d] '%s'\n", $conn->errno, $conn->error);

	var_dump($res->fetch_assoc());
	$res->close();

	mysqlnd_uh_set_connection_proxy(new proxy());
	mysqlnd_uh_test\query_test::mysqli($conn);

	if (!$conn->real_query("SELECT 'with proxy' FROM DUAL"))
		printf("[003] [%d] '%s'\n", $conn->errno, $conn->error);

	if (!$res = $conn->use_result())
		printf("[004] [%d] '%s'\n", $conn->errno, $conn->error);

	var_dump($res->fetch_assoc());
	$res->close();

	mysqlnd_uh_set_connection_proxy(new proxy2(), $conn);

	if (!$conn->real_query("SELECT 'with proxy' FROM DUAL"))
		printf("[005] [%d] '%s'\n", $conn->errno, $conn->error);

	if (!$res = $conn->use_result())
		printf("[006] [%d] '%s'\n", $conn->errno, $conn->error);

	var_dump($res->fetch_assoc());
	$res->close();

	print "done!";
?>
--EXPECTF--
array(1) {
  ["without proxy"]=>
  string(13) "without proxy"
}
proxy::useResult(array (
  0 => NULL,
))
resource(%d) of type (MySQLnd Resultset (internal only - you must not modify it!))
array(1) {
  ["with proxy"]=>
  string(10) "with proxy"
}
proxy2::useResult(array (
  0 => NULL,
))
resource(%d) of type (MySQLnd Resultset (internal only - you must not modify it!))
[006] [0] ''

Fatal error: Call to a member function fetch_assoc() on a non-object in %s on line %d